package com.platform.data.handle.converter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.Objects;

/**
 * 数据类型枚举类
 *
 * @author zhuweijun
 * @version 1.0.0
 * @since 2025/5/13 11:40
 */
public enum DataTypeEnum {

    STRING("S", "String", null, "字符串"),
    INTEGER("I", "Integer", null,"整数"),
    BIG_DECIMAL_1("D1", "BigDecimal", 1,"浮点型，保留一位小数"),
    BIG_DECIMAL_2("D2", "BigDecimal", 2,"浮点型，保留两位小数"),
    BIG_DECIMAL_3("D3", "BigDecimal", 3,"浮点型，保留三位小数"),
    BIG_DECIMAL_4("D4", "BigDecimal", 4,"浮点型，保留四位小数"),
    BIG_DECIMAL_5("D5", "BigDecimal", 5,"浮点型，保留五位小数"),
    BIG_DECIMAL_6("D6", "BigDecimal", 6,"浮点型，保留六位小数"),
    BIG_DECIMAL_7("D7", "BigDecimal", 7,"浮点型，保留七位小数"),
    BIG_DECIMAL_8("D8", "BigDecimal", 8,"浮点型，保留八位小数"),
    ARRAY("A", "List", null,"数组，对象"),
    ARRAY_STRING("AS", "List_String", null,"数组，字符串"),
    ARRAY_INTEGER("AI", "List_Integer", null,"数组，整数"),
    ENUM_STRING("ES", "Enum_String", null, "枚举值，字符串"),
    ENUM_INTEGER("EI", "Enum_Integer", null, "枚举值，整数"),
    DATE_STRING("DS", "Date_String", null, "日期，字符串(yyyy-MM-dd)"),
    ;

    /**
     * 类型标识
     */
    private final String type;

    /**
     * 处理类型
     */
    private final String processType;

    /**
     * 保留小数位数（浮点数）
     */
    private final Integer decimalPlace;

    /**
     * 描述
     */
    private final String desc;

    DataTypeEnum(String type, String processType, Integer decimalPlace, String desc) {
        this.type = type;
        this.processType = processType;
        this.decimalPlace = decimalPlace;
        this.desc = desc;
    }

    public String getType() {
        return type;
    }

    public String getProcessType() {
        return processType;
    }

    public Integer getDecimalPlace() {
        return decimalPlace;
    }

    public String getDesc() {
        return desc;
    }

    public static DataTypeEnum getEnum(String type) {
        for (DataTypeEnum anEnum : DataTypeEnum.values()) {
            if(Objects.equals(anEnum.type, type)){
                return anEnum;
            }
        }
        return null;
    }
}
